<template>
  <!-- 充值-->
  <el-dialog
    v-el-drag-dialog
    :title="title"
    :visible.sync="visible"
    width="60%"
    append-to-body
    @close="reset"
  >
    <el-form ref="dataForm" class="form" label-position="left" label-width="80px">
      <el-form-item label-width="0" class="block">
        <el-input v-model.trim="search.param" style="width: 300px;" placeholder="请输入">
          <el-select slot="prepend" v-model="qtype" style="width: 100px;" placeholder="请选择">
            <el-option label="客户电话" value="csmRgPhone" />
            <el-option label="客户编号" value="csmCode" />
          </el-select>
        </el-input>
        <el-button style="margin-left: 10px;" type="primary" @click="searchTxt">查询</el-button>
      </el-form-item>
    </el-form>
    <lb-table
      ref="lbTable"
      v-el-height-adaptive-table="{bottomOffset:10}"
      border
      class="table-list"
      highlight-current-row
      element-loading-text="加载中"
      :column="tableData.column"
      :data="tableData.data"
      pagination
      :total="tableData.total"
      custom-column
      :immediate-fetch="false"
      @select="dialogCheck"
      @fetch="fetchData"
    />
    <!-- 开通月结 -->
    <div v-if="cradType===1" class="item">
      <div class="title">
        <span class="title-icon" />
        <span class="title-text">额度设置</span>
      </div>
      <el-form ref="dataFormCharge" class="form" label-position="right" label-width="150px" :model="temp" :rules="rulesCharge">
        <el-form-item label="使用门店:" prop="useOrgSNNo">
          <el-tree-select
            v-model="temp.useOrgSNNo"
            class="tree-select"
            :popover-width="360"
            :select-params="{
              clearable: true,
              placeholder: '请选择',
              loading: $loadingPlugin.getTreeData,
            }"
            :tree-params="{
              'expand-on-click-node': false,
              'highlight-current': true,
              'filterable': true,
              props: {
                value: 'orgSNNo',
                label: 'orgName',
                disabled: 'disabled',
              },
              data: treeData,
            }"
            @node-click="selectTreeChange"
          />
        </el-form-item>
        <el-form-item label="月结授信额度:" prop="decimalSpare2">
          <el-input v-model="temp.decimalSpare2" placeholder="请输入" type="number" @input="onInput($event)" @blur="formatInput($event)" />
        </el-form-item>
        <el-form-item label="备注:" style="width: 100%;" label-width="90px">
          <el-input v-model="temp.remark" type="textarea" resize="none" :maxlength="250" placeholder="请输入" />
        </el-form-item>
      </el-form>
    </div>
    <!-- 额度调整 -->
    <div v-if=" cradType===2 " class="item">
      <div class="title">
        <span class="title-icon" />
        <span class="title-text">额度设置</span>
      </div>
      <el-form ref="dataFormCharge" class="form" label-position="right" label-width="180px" :model="temp" :rules="rulesCharge">
        <el-form-item label="当前月结授信额度:">
          <el-input v-model="decimalSpare2" placeholder="请输入" :disabled="true" />
        </el-form-item>
        <el-form-item label="修改额度为:" prop="decimalSpare2">
          <el-input v-model="temp.decimalSpare2" placeholder="请输入" type="number" @input="onInput($event)" @blur="formatInput($event)" />
        </el-form-item>
        <el-form-item label="当前剩余可用额度:">
          <el-input v-model="decimalSpare3" placeholder="请输入" :disabled="true" />
        </el-form-item>
        <el-form-item label="备注:" style="width: 100%;" label-width="90px">
          <el-input v-model="temp.remark" type="textarea" resize="none" :maxlength="250" placeholder="请输入" />
        </el-form-item>
      </el-form>
    </div>
    <!-- 关闭月结 -->
    <div v-if="cradType===3" class="item">
      <el-form ref="dataForm" class="form" label-position="right" label-width="100px">
        <el-form-item label="备注信息:" style="width: 100%;" label-width="100px">
          <el-input v-model="temp.remark" type="textarea" resize="none" :maxlength="250" placeholder="请输入" />
        </el-form-item>
      </el-form>
    </div>
    <!-- 手机号变更 -->
    <div v-if=" cradType===4 " class="item">
      <div class="title">
        <span class="title-icon" />
        <span class="title-text">手机号变更</span>
      </div>
      <el-form ref="dataForm" class="form" label-position="right" label-width="144px">
        <el-form-item label="原绑定手机号:">
          <el-input v-model="csmInfo.csmPhone" placeholder="请输入" :disabled="true" />
        </el-form-item>
        <el-form-item label="变更后绑定手机号:" label-width="190px">
          <el-select v-model="csmPhone" style="width: 100%;" placeholder="请选择">
            <el-option
              v-for="(i, ind) in phoneItems"
              :key="ind"
              :label="i.csmPhone"
              :value="i.csmPhone"
            />
          </el-select>
        </el-form-item>
        <el-form-item label="备注信息:" style="width: 100%;" label-width="90px">
          <el-input v-model="temp.remark" type="textarea" resize="none" :maxlength="250" placeholder="请输入" />
        </el-form-item>
      </el-form>
    </div>
    <div slot="footer" class="dialog-footer">
      <el-button @click="reset">关闭</el-button>
      <el-button type="primary" @click="onSubmit">保存</el-button>
    </div>
  </el-dialog>
</template>

<script>
  import {
    queryMap,
    customerByPhoneAndCsmCode,
    monthCustomerByPhoneAndCsmCode,
    saveMonthlyCustomer,
    closeMonthlyCustomer,
    updateCustomerMonthlyPhone,
    selectCsmPhoneList,
    topUpAdministrationInfoInfo,
    topUpAdministrationUserInfo,
    topUpAdministratioTradePrice } from '@/api'
  import { parseTime, formatColumnMap } from '@/utils'
  import { mergeAsyncFunc } from '@/utils/mergeAsyncFunc'
  import getTreeData from '@/utils/jsonTree'
  import { mapGetters } from 'vuex'
  export default {
    name: 'crad-operate',
    components: {
    },
    props: {
    },
    data() {
      return {
        treeData: [],
        formatColumnMap,
        title: '',
        cradType: null,
        userInfo: {},
        qtype: 'csmRgPhone',
        search: {
          param: ''
        },
        customerTypeMap: [],
        tableData: {
          total: 0,
          data: [],
          column: [
            {
              type: 'index'
            },
            {
              type: 'selection'
            },
            {
              prop: 'csmCode',
              label: '客户编号'
            },
            {
              prop: 'csmName',
              label: '客户名称',
              showOverflowTooltip: true
            },
            {
              prop: 'csmType',
              label: '客户类型',
              render: (h, { row }) => <span>{ row.csmType && formatColumnMap(this.customerTypeMap, 'value', row.csmType, 'desc') }</span>
            },
            {
              prop: 'nearStationName',
              label: '所属机构',
              showOverflowTooltip: true
            },
            {
              prop: 'useOrgName',
              label: '使用门店',
              showOverflowTooltip: true
            },
            {
              prop: 'csmRgPhone',
              label: '客户电话',
              showOverflowTooltip: true
            }
          ]
        },
        selectioned: null,
        decimalSpare2: null,
        decimalSpare3: null,

        csmcardMax: 0,
        parseTime,
        visible: false,
        type: null,
        cardCode: '',
        csmInfo: {},
        phoneItems: [],
        curtainTy: 1, // 调账类型
        csmPhone: '', // 变更后绑定手机号
        isText: true,
        temp: {
          feeCount1: '',
          feeCount2: '0.00',
          decimalSpare2: null,
          remark: '',
          cardFee: 0,
          money: '',
          companyName: '', // 企业名称
          bankName: '', // 开户银行
          bankAccount: '', // 账户号码
          backup: '', // 备用字段
          useOrgId: null,
          useOrgName: '',
          useOrgSNNo: ''
        },
        // 修改密码
        pas: {
          password1: '', // 原密码
          password2: '', // 新密码
          password3: '' // 再次输入的新密码
        },
        rules: {
          password1: [{ required: true, message: '请输入原密码', trigger: 'change' }, { min: 6, max: 6, message: '请输入六位数密码', trigger: 'blur' }],
          password2: [{ required: true, message: '请输入新密码', trigger: 'change' }, { min: 6, max: 6, message: '请输入六位数新密码', trigger: 'blur' }],
          password3: [{ required: true, message: '请再次输入新密码', trigger: 'change' }, { min: 6, max: 6, message: '请再次输入六位数新密码', trigger: 'blur' }],
          companyName: [
            { required: true, message: '请输入企业名称', trigger: 'change' }
          ],
          bankName: [
            { required: true, message: '请输入开户银行', trigger: 'change' }
          ],
          bankAccount: [
            { required: true, message: '请输入账户号码', trigger: 'change' }
          ]
        },
        rulesCharge: {
          useOrgSNNo: [{ required: true, message: '请选择使用门店', trigger: 'change' }],
          decimalSpare2: [{ required: true, message: '请输入额度', trigger: 'change' }]
        },
        // 调账
        price: {
          updateCashMoney: 0.00, // 现金卡值调整
          changeCashMoney1: 0.00, // 初始数据现金卡值
          changeSendMoney1: 0.00, // 初始数据赠送卡值调整
          changeCardSurplus1: 0.00, // 初始数据调整后卡余额/余次
          updateSendMoney: 0.00, // 赠送卡值调整
          changeCashMoney: 0.00, // 调整后现金卡值
          changeSendMoney: 0.00, // 调整后赠送卡值
          changeCardSurplus: 0.00// 调整后卡余额
        }
      }
    },
    computed: {
      ...mapGetters(['orgList'])
    },
    watch: {
      cradType(value) {
        if (value !== 1) {
          if (this.tableData.column.length === 10) {
            return
          }
          this.tableData.column.push({
                                       prop: 'decimalSpare2',
                                       label: '授信额度'
                                     },
                                     {
                                       prop: 'decimalSpare3',
                                       label: '剩余额度'
                                     })
        } else {
          if (this.tableData.column.length >= 10) {
            this.tableData.column = this.tableData.column.slice(0, 8)
          }
        }
      }
    },
    async created() {
      await this.queryOptionsMap()
      await this.getTreeData()
    },
    methods: {
      // 获取适用门店数据
      async getTreeData() {
        const data = this.orgList.map((item) => ({
          label: item.orgName,
          ...item
        }))
        this.treeData = getTreeData(data)
      },
      // 查询枚举
      async queryOptionsMap() {
        const [res1] = await Promise.all([mergeAsyncFunc(queryMap, { enumName: 'CustomerType' })])
        this.customerTypeMap = res1.data // 客户类型
      },
      async fetchData({ currentPage, pageSize }) {
        const params = {
          pageIndex: currentPage,
          pageSize
        }
        if (this.search.param !== '') {
          params.json = {
            [this.qtype]: this.search.param
          }
        }
        let res = null
        if (this.cradType === 1) {
          res = await customerByPhoneAndCsmCode(params)
        } else {
          res = await monthCustomerByPhoneAndCsmCode(params)
        }

        this.tableData.data = res.data.rows
        if (currentPage === 1) this.tableData.total = res.data.total
        // this.open({ cardCode: this.userInfo.cardCode, type: this.cradType, title: this.title })
      },
      // 选择开户门店
      selectTreeChange(value) {
        this.temp.useOrgId = value.orgId
        this.temp.useOrgName = value.orgName
        this.temp.useOrgSNNo = value.orgSNNo
      },
      async searchTxt() {
        // 电话校验
        if (this.qtype === 'csmRgPhone') {
          if (!this.search.param) {
            this.$message({
              type: 'warning',
              message: '请输入电话号码'
            })
            return
          }
          this.$refs.lbTable.fetch({ currentPage: 1 })
        // 卡号校验
        } else if (this.qtype === 'csmCode') {
          if (!this.search.param) {
            this.$message({
              type: 'warning',
              message: '请输入客户编号'
            })
            return
          }
          this.$refs.lbTable.fetch({ currentPage: 1 })
        }
      },
      // 勾选
      async dialogCheck(selection, row) {
        this.$refs.lbTable.clearSelection()
        if (selection.length === 0) { // 判断selection是否有值存在
          return
        }
        if (row) {
          if (row.settlementType === 2 && this.cradType === 1) {
            this.$message.error('该用户已是月结客户无法开通！')
            return
          }
          // this.open({ cardCode: row.cardCode, type: this.cradType, title: this.title })
          if (row.settlementType === 1 && this.cradType === 2) {
            this.$message.error('非月结客户无法调整额度！')
            return
          }
          if (row.settlementType === 1 && this.cradType === 3) {
            this.$message.error('非月结客户无法关闭！')
            return
          }
          if (row.settlementType === 1 && this.cradType === 4) {
            this.$message.error('非月结客户无法变更手机号！')
            return
          }
          if (this.cradType === 2) {
            this.decimalSpare2 = row.decimalSpare2
            this.decimalSpare3 = row.decimalSpare3
          }
          if (this.cradType === 4) {
            this.csmInfo.csmPhone = row.csmRgPhone
            const res = await selectCsmPhoneList({ csmId: row.csmId })
            this.phoneItems = res.data
          }
          this.selectioned = row
          this.$refs.lbTable.toggleRowSelection(row, true)
        }
      },
      rowClick(row) {
        // 根据充值卡状态,找出不支持的操作
        const backInfo = this.selectCardStatus(row.cardStatus)
        if (!backInfo.status) {
          this.$message({
            type: 'warning',
            message: `${backInfo.msg}`
          })
        } else {
          // 检索成功------打开别的弹框
          this.open({ cardCode: row.cardCode, type: this.cradType, title: this.title })
        }
      },
      async open(data) {
        console.log('ddddd', data)
        this.maxPrice()
        const { cardCode, type, title } = data
        this.type = type
        this.title = title
        await Promise.all([this.getUserInfo(cardCode)])
        return new Promise(resolve => {
          this.resolve = resolve
          this.visible = true
        })
      },
      async maxPrice() {
        const res = await topUpAdministratioTradePrice()
        console.log(res)
        this.csmcardMax = res.data && (res.data.csmcardMax / 100).toFixed(2)
        this.temp.cardFee = res.data && (res.data.wordFeeOne / 100).toFixed(2)
      },
      // 提交
      async onSubmit() {
        if (!this.selectioned) {
          this.$message.error('请选择客户！')
          return
        }
        switch (this.cradType) {
        case 1: // 开通月结
          this.$refs.dataFormCharge.validate(valid => {
            if (!valid) return
            this.$confirm('确认开通月结？', '提示', {
              confirmButtonText: '确定',
              cancelButtonText: '取消',
              type: 'warning'
            }).then(async() => {
              const json = {
                csmId: this.selectioned.csmId,
                csmCode: this.selectioned.csmCode,
                csmName: this.selectioned.csmName,
                csmRgPhone: this.selectioned.csmRgPhone,
                decimalSpare2: this.temp.decimalSpare2,
                remark: this.temp.remark,
                useOrgId: this.temp.useOrgId,
                useOrgName: this.temp.useOrgName,
                useOrgSNNo: this.temp.useOrgSNNo
              }
              const res = await saveMonthlyCustomer({ json })
              if (res.status === 200) {
                this.$message({
                  type: 'success',
                  message: '开通月结成功！'
                })
                this.visible = false
              }
            })
          })

          break
        case 2: // 调整额度
          this.$refs.dataFormCharge.validate(valid => {
            if (!valid) return
            this.$confirm('确认调整额度？', '提示', {
              confirmButtonText: '确定',
              cancelButtonText: '取消',
              type: 'warning'
            }).then(async() => {
              const json = {
                csmId: this.selectioned.csmId,
                csmCode: this.selectioned.csmCode,
                csmName: this.selectioned.csmName,
                csmRgPhone: this.selectioned.csmRgPhone,
                decimalSpare2: this.temp.decimalSpare2,
                remark: this.temp.remark
              }
              const res = await saveMonthlyCustomer({ json })
              if (res.status === 200) {
                this.$message({
                  type: 'success',
                  message: '调整额度成功！'
                })
                this.visible = false
              }
            })
          })
          break
        case 3: // 关闭月结
          this.$confirm('确认关闭月结？', '提示', {
            confirmButtonText: '确定',
            cancelButtonText: '取消',
            type: 'warning'
          }).then(async() => {
            const json = {
              csmId: this.selectioned.csmId,
              csmCode: this.selectioned.csmCode,
              csmName: this.selectioned.csmName,
              csmRgPhone: this.selectioned.csmRgPhone,
              remark: this.temp.remark
            }
            const res = await closeMonthlyCustomer({ json })
            if (res.status === 200) {
              this.$message({
                type: 'success',
                message: '关闭月结成功！'
              })
              this.visible = false
            }
          })
          break
        case 4: // 手机号变更
          if (!this.csmPhone) {
            this.$message.error('请选择更换的手机号')
            return
          }
          if (this.csmInfo.csmPhone === this.csmPhone) {
            this.$message({
              type: 'warning',
              message: '更换后的电话与原电话不能相同'
            })
            return
          }
          this.$confirm('确认变更手机号？', '提示', {
            confirmButtonText: '确定',
            cancelButtonText: '取消',
            type: 'warning'
          }).then(async() => {
            var json = {
              csmId: this.selectioned.csmId,
              csmRgPhone: this.csmPhone,
              remark: this.temp.remark
            }
            var res2 = await updateCustomerMonthlyPhone({ json })
            if (res2.status === 200) {
              this.$message({
                type: 'success',
                message: '更改绑定手机号成功！'
              })
              this.visible = false
            }
          })
          break
        }
      },
      reset() {
        clearInterval(this.timer)
        this.userInfo = {}
        this.tableData.data = []
        this.messageCode = ''
        this.search = {
          param: ''
        }
        this.qtype = 'csmRgPhone'
        this.cradType = null
        this.$nextTick(() => {
          this.visible = false
        })
        this.decimalSpare2 = null
        this.decimalSpare3 = null
        this.visible = false
        this.type = null
        this.title = ''
        this.cardCode = ''
        this.csmInfo = {}
        this.phoneItems = []
        this.curtainTy = 1 // 调账类型
        this.csmPhone = '' // 变更后绑定手机号
        this.isText = true
        this.temp = {
          feeCount1: '',
          feeCount2: '0.00',
          remark: '',
          cardFee: 0,
          money: '',
          companyName: '', // 企业名称
          bankName: '', // 开户银行
          bankAccount: '', // 账户号码
          backup: '', // 备用字段
          useOrgId: null,
          useOrgName: '',
          useOrgSNNo: ''
        }
        // 修改密码
        this.pas = {
          password1: '', // 原密码
          password2: '', // 新密码
          password3: '' // 再次输入的新密码
        }
        // 调账
        this.price = {
          updateCashMoney: 0.00, // 现金卡值调整
          changeCashMoney1: 0.00, // 初始数据现金卡值
          changeSendMoney1: 0.00, // 初始数据赠送卡值调整
          changeCardSurplus1: 0.00, // 初始数据调整后卡余额/余次
          updateSendMoney: 0.00, // 赠送卡值调整
          changeCashMoney: 0.00, // 调整后现金卡值
          changeSendMoney: 0.00, // 调整后赠送卡值
          changeCardSurplus: 0.00// 调整后卡余额
        }
      },
      async formatInput(e) {
        // if (this.type === 5) {
        //   this.temp.money = (e.target.value * 1).toFixed(2)
        //   return
        // }
        // if (e.target.value) {
        //   this.temp.feeCount1 = (e.target.value * 1).toFixed(2)
        //   const res = await topUpAdministrationPrice({ feeCount1: this.temp.feeCount1 * 100 })
        //   var result = res.data // 赠送金额
        //   if (result !== 0) {
        //     result = result * 1.00 / 100
        //     result = isNaN(result) ? '0.00' : result.toFixed(2)
        //   }
        //   // 赠送金额
        //   this.temp.feeCount2 = result === 0 ? 0.00 : result
        //   // 设置卡内余额
        //   this.temp.cardStatus = this.temp.feeCount1
        //   // 设置应收金额
        //   this.temp.totalPrice = (this.temp.feeCount1 * 1) + (result * 1) + (this.temp.cardFee * 1)
        // }
      },
      // 请求用户信息接口
      async getUserInfo(cardCode) {
        const res = await topUpAdministrationInfoInfo({
          cardCode: cardCode
        })
        console.log('用户信息', res)
        this.csmInfo = res.data
        this.temp.companyName = res.data.companyName // 企业名称
        this.temp.bankName = res.data.bankName // 开户银行
        this.temp.bankAccount = res.data.bankAccount // 账户号码
        this.temp.backup = res.databackup
        // 初始数据
        this.price.changeCashMoney1 = this.numberFormat1(this.csmInfo.cashMoney)// 初始数据现金卡值
        this.price.changeSendMoney1 = this.numberFormat1(this.csmInfo.sendMoney)// 初始数据赠送卡值调整
        this.price.changeCardSurplus1 = this.numberFormat1(this.csmInfo.cardSurplus)// 初始数据调整后卡余额/余次
        // 调整后
        this.price.cashMoney = this.numberFormat1(this.csmInfo.cashMoney)
        this.price.changeCashMoney = this.numberFormat1(this.csmInfo.cashMoney)// 调整后现金卡值
        this.price.changeSendMoney = this.numberFormat1(this.csmInfo.sendMoney)// 调整后赠送卡值
        this.price.changeCardSurplus = this.numberFormat1(this.csmInfo.cardSurplus)// 调整后卡余额/余次
        // 查询客户状态
        var res1 = await topUpAdministrationUserInfo({
          csmStatus: 9, // 查询状态不是已注销的客户
          csmCode: this.csmInfo.csmCode
        })
        console.log('客户状态', res1)
        if (res1.data && res1.data.csmStatus === 1) {
          this.$message({
            type: 'warning',
            message: '当前客户未审核'
          })
          return
        }
        if (res1.data && res1.data.csmStatus === 3) {
          this.$message({
            type: 'warning',
            message: '当前客户已挂失'
          })
          return
        }
        if (res1.data && res1.data.phoneItems && res1.data.phoneItems.length) {
          this.phoneItems = res1.data.phoneItems.filter(item => {
            return item.cpStatus === 2
          })
          if (this.phoneItems.length > 0) {
            this.csmPhone = this.phoneItems[0].csmPhone
          }
        }
      },
      // 调账冲正
      onMoney(e, is) {
        if (!e.target.value) {
          e.target.value = 0.00
          e.target.value = 0.00
        }
        if (e.target.value) {
          if (is === 'updateCashMoney') {
            if (this.curtainTy === 1) {
              this.price.updateCashMoney = (e.target.value * 1).toFixed(2)
              // 调整后现金卡值
              this.price.changeCashMoney = ((this.price.updateCashMoney * 1) + (this.price.changeCashMoney1 * 1)).toFixed(2)
              // 调整后卡余额/余次
              this.price.changeCardSurplus = ((this.price.updateCashMoney * 1) + (this.price.changeCardSurplus1 * 1) + (this.price.updateSendMoney * 1)).toFixed(2)
            } else {
              this.price.updateCashMoney = (e.target.value * 1).toFixed(2)
              // 调整后现金卡值
              this.price.changeCashMoney = ((this.price.changeCashMoney1 * 1) - (this.price.updateCashMoney * 1)).toFixed(2)
              // 调整后卡余额/余次
              this.price.changeCardSurplus = ((this.price.changeCardSurplus1 * 1) - (this.price.updateCashMoney * 1) - (this.price.updateSendMoney * 1)).toFixed(2)
            }
          } else {
            if (this.curtainTy === 1) {
              this.price.updateSendMoney = (e.target.value * 1).toFixed(2)
              // 赠送卡值调整
              this.price.changeSendMoney = ((this.price.updateSendMoney * 1) + (this.price.changeSendMoney1 * 1)).toFixed(2)
              // 调整后卡余额/余次
              this.price.changeCardSurplus = ((this.price.updateCashMoney * 1) + (this.price.changeCardSurplus1 * 1) + (this.price.updateSendMoney * 1)).toFixed(2)
            } else {
              this.price.updateSendMoney = (e.target.value * 1).toFixed(2)
              // 赠送卡值调整
              this.price.changeSendMoney = ((this.price.changeSendMoney1 * 1) - (this.price.updateSendMoney * 1)).toFixed(2)
              // 调整后卡余额/余次
              this.price.changeCardSurplus = ((this.price.changeCardSurplus1 * 1) - (this.price.updateSendMoney * 1) - (this.price.updateCashMoney * 1)).toFixed(2)
            }
          }
        }
      },
      //
      changeGroup(val) {
        if (val === 1) {
          this.price.updateCashMoney = (this.price.updateCashMoney * 1).toFixed(2)
          // 调整后现金卡值
          this.price.changeCashMoney = ((this.price.updateCashMoney * 1) + (this.price.changeCashMoney1 * 1)).toFixed(2)
          // 调整后赠送卡值
          this.price.changeSendMoney = ((this.price.updateSendMoney * 1) + (this.price.changeSendMoney1 * 1)).toFixed(2)
          // 调整后卡余额
          this.price.changeCardSurplus = ((this.price.updateCashMoney * 1) + (this.price.changeCardSurplus1 * 1) + (this.price.updateSendMoney * 1)).toFixed(2)
        } else {
          this.price.updateCashMoney = (this.price.updateCashMoney * 1).toFixed(2)
          // 调整后现金卡值
          this.price.changeCashMoney = ((this.price.changeCashMoney1 * 1) - (this.price.updateCashMoney * 1)).toFixed(2)
          // 调整后赠送卡值
          this.price.changeSendMoney = ((this.price.changeSendMoney1 * 1) - (this.price.updateSendMoney * 1)).toFixed(2)
          // 调整后卡余额
          this.price.changeCardSurplus = ((this.price.changeCardSurplus1 * 1) - (this.price.updateCashMoney * 1) - (this.price.updateSendMoney * 1)).toFixed(2)
        }
      },
      // 充值金额
      onInput(value, is) {
        const res = value
          .replace(/[^\d.]/g, '')
          .replace(/\.{2,}/g, '.')
          .replace(/^\./g, '')
          .replace('.', '$#$')
          .replace(/\./g, '')
          .replace('$#$', '.')
          .replace(/^0\d+|^\./g, '')
          .replace(/^(.*\..{2}).*$/, '$1')
        if (this.cradType === 1 || this.cradType === 2) {
          if (res > 20000000) {
            this.temp.decimalSpare2 = 20000000
          }
          // console.log(res)
          // if(res<0){
          //   this.temp.decimalSpare2 = 0
          // }
          return
        }
        this.temp.feeCount1 = res
        this.temp.money = res
      },
      // 充值金额
      numberFormat1: function(val) {
        val = val * 1.00 / 100
        val = Number(val)
        val = isNaN(val) ? '0.00' : val.toFixed(2)
        return val
      }
    }
  }
</script>

<style lang="scss" scoped>
.item {
  margin-bottom: 30px;
  .title {
    display: flex;
    align-items: center;
    margin-bottom: 20px;
    .title-icon {
      display: inline-block;
      width: 4px;
      height: 18px;
      margin-right: 6px;
      background: #01999f;
    }
    .title-text {
      font-family: Microsoft YaHei, Microsoft YaHei-Bold;
      font-size: 14px;
      font-weight: 700;
      color: #01999f;
    }
  }
  &:last-child {
    margin-bottom: 0;
  }
  .content {
    margin-bottom: 30px;
  }
  .form {
    display: flex;
    flex-wrap: wrap;
    & /deep/ .el-form-item {
      display: flex;
      width: 50%;
      padding-right: 10px;
      .el-form-item__content {
        width: 100%;
      }
    }

    /deep/.el-form-item__content {
      margin-left: 10px !important;
    }
    span {
      margin-left: 6px;
      span {
        font-size: 14px;
        color: red;
      }
    }
  }
}
.remark-changecard {
  /deep/.el-form-item__content {
    width: 80%;
  }
}
.change-cardfee {
  width: 50% !important;
}
.table-list {
  width: 100%;
  height: 250px;
  /deep/ .el-table {
    height: 200px !important;
    overflow: auto;
    .el-table__body-wrapper {
      height: auto !important;
    }
  }
  /deep/ .has-gutter {
    .el-checkbox {
      display: none;
    }
  }
}
</style>
